<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.util.*,lib.base.*"%>
 <%@ taglib uri="../../WEB-INF/translate.tld" prefix="ego" %>
<%
String date_year = request.getParameter("date").substring(0, 4);
String date_month = request.getParameter("date").substring(4, 6);
String date_day = request.getParameter("date").substring(6);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<link rel="stylesheet" type="text/css" href="pub/dojo/dojo/resources/dojo.css" />
	<link rel="stylesheet" type="text/css" href="pub/dojo/dijit/themes/tundra/tundra.css" />
	<script type="text/javascript" src="pub/dojo/dojo/dojo.js" djConfig="parseOnLoad: true"></script> 

	<script type="text/javascript" src="pub/js/debug.js"></script>
	<script type="text/javascript" src="modules/event/script.js"></script>
	<script type="text/javascript">
	<!-- 
	var start_date = new Date();
	start_date.setFullYear(<%= date_year+",("+date_month+"-1),"+date_day %>);
	start_date.setSeconds(0);
	start_date.setHours(0);
	start_date.setMilliseconds(0);

	var end_date = new Date();
	end_date.setTime(start_date.getTime());

	var employee_remaining_leave = <%= request.getAttribute("remainingLeave") %>;
	var employee_workingDays = <%= request.getAttribute("workingDays") %>;
	
	var employee_allHolidays_accepted = [];
	var employee_allHolidays_denied = [];
	var employee_allHolidays_requested = [];
	<%
	ArrayList<EgoHoliday> h = (ArrayList<EgoHoliday>) request.getAttribute("allHolidays");
	for (int i=0; i<h.size(); i++)
	{
		ArrayList<String> d = h.get(i).getDays();
		for (int ii=0; ii<d.size(); ii++)
		{
			if (h.get(i).getStatus().equals( EgoHoliday.STATUS_ACCEPTED ))
			{
	%>
				employee_allHolidays_accepted.push('<%= d.get(ii) %>');
	<%
			} else if (h.get(i).getStatus().equals( EgoHoliday.STATUS_DENIED ))
			{ // denied
	%>
				employee_allHolidays_denied.push('<%= d.get(ii) %>');
	<%
			} else if (h.get(i).getStatus().equals( EgoHoliday.STATUS_REQUESTED ))
			{ // requested
	%>
				employee_allHolidays_requested.push('<%= d.get(ii) %>');
	<%
			}
		}
	} %>

	var employee_allPublicHolidays = [];
	<%
	ArrayList<String> d = (ArrayList<String>) request.getAttribute("allPublicHolidays");
	for (int i=0; i<d.size(); i++)
	{ %>
			employee_allPublicHolidays.push('<%= d.get(i) %>');
	<% } %>
	
	//-->
	</script>
	
	<style type="text/css">
	.noWorkingDay {
		background-color:#F8F8F8 !important;
		color:#999999;
	}
	.leaveDay_requested {
		background-color:#FFA0A0 !important;
	}
	.leaveDay_denied {
		background-color:#FFD0D0 !important;
	}
	.leaveDay_accepted {
		background-color:#00DD00 !important;
	}
	.timespanDay, .dijitCalendarSelectedDate {
		background-color:#A0A0FF !important;
	}
	.publicHoliday {
		background-color:#A0FFA0 !important;
	}
	#legende {
		margin:8px 0 0 0;
	}
	#legende .box {
		float:left;
		width:10px;
		height:10px;
	}
	#legende .text {
		float:left;
		margin: -2px 0 0 1px;
	}
	#overlapping {
		color:red;
		text-weight: bold;
	}
	</style>
</head>
<body class="tundra" style="overflow:hidden">
<center>
	<img src="pub/img/login-loading.gif" id="img" />
	
	<div id="form" style="visibility:hidden">
		<div dojoType="dijit.layout.AccordionContainer" id="accordion" region="leading" minSize="80" style="width:99%; height:251px" splitter="true"> 
			<div dojoType="dijit.layout.AccordionPane" title="<ego:t>Last leave day</ego:t>">
				<div id="calendar1" dojoType="dijit._Calendar" getClassForDate="get_class_for_date">
					<script type="dojo/connect" event="onValueSelected" args="value">
						if (this.currentYearLabelNode.innerHTML != start_date.getFullYear())
						{
							this.attr('value', start_date);
						}
						load_days();
					</script>
				</div>
				<table id="legende">
					<tr>
						<td>
							<div class="box" style="background-color:#00DD00;">&nbsp;</div>
							<div class="text">accepted</div>
						</td>
						<td>
							<div class="box" style="background-color:#A0FFA0;">&nbsp;</div>
							<div class="text">public holiday</div>
						</td>
					</tr>
					<tr>
						<td>
							<div class="box" style="background-color:#FFA0A0;">&nbsp;</div>
							<div class="text">requested</div>
						</td>
						<td>
							<div class="box" style="background-color:#FFD0D0;">&nbsp;</div>
							<div class="text">denied</div>
						</td>
					</tr>
				</table>
				<div id="overlapping" style="display:none">Overlapping with other holidays detected.</div>
			</div>
		</div>
		<% if (request.getAttribute("entitlementLeave").toString().equals("0.0")) { %>
			<ego:t>You do not have entitlement to holidays</ego:t>.
		<% } else { %>
			<div><ego:t>remaining leave</ego:t></div>
			<div style="width:95%" maximum="<%= request.getAttribute("entitlementLeave") %>" id="remainingLeave" progress="0" dojoType="dijit.ProgressBar">
				<script type="dojo/method" event="report">
					return this.progress+" / "+this.maximum;
				</script>
			</div>
		<% } %>
		<button dojoType="dijit.form.Button" type="button" id="submit" style="position:absolute;left:0;bottom:0" onClick="sendData()">
			<ego:t>Request leave</ego:t>
		</button>
		<div style="position:absolute;right:0;bottom:4px">
			<label for="global_length_half"><ego:t>Half day</ego:t></label>
			<input type="checkbox" id="global_length_half" dojoType="dijit.form.CheckBox" onclick="calc_remaining_leave()" />
		</div>
		
		<div jsId="dialog_wait" dojoType="dijit.Dialog" title="<ego:t>Creating leave</ego:t>" style="width:130px;text-align:center">
			<img src="pub/img/login-loading.gif" /><br/>
			<ego:t>Please wait</ego:t>...
		</div>
	</div>
</center>
</body>
</html>
